# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=detectem
pkgver=276.bc5f073
_pyver=3.13
pkgrel=12
pkgdesc='Detect software and its version on websites.'
groups=('blackarch' 'blackarch-fingerprint' 'blackarch-webapp'
        'blackarch-recon')
arch=('any')
url='https://github.com/spectresearch/detectem'
license=('MIT')
depends=('python' 'python-requests' 'python-pytest' 'python-docker'
         'python-click' 'python-yaml' 'python-zope-interface' 'python-dukpy'
         'python-parsel' 'python-click-log' 'python-environs')
makedepends=('git' 'python-setuptools')
source=("git+https://github.com/spectresearch/$pkgname.git"
        'base.txt.patch')
sha512sums=('SKIP'
            '8b2b465aa775c8734372bd96a7ddaba1bd8c263a605cd4c23ca8ab3417b496459a6372a3f7f2a7fabc3a0afaaaa9b300850df89db1a9f8acaeaca34b8a6456d8')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd "$pkgname/requirements"

  patch -p0 < "$srcdir/base.txt.patch"
}

build() {
  cd $pkgname

  python setup.py build
}

package() {
  cd $pkgname

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" *.md *.rst
  cp -a docs/* "$pkgdir/usr/share/doc/$pkgname/"
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  mv "$pkgdir/usr/bin/det" "$pkgdir/usr/bin/$pkgname"

  rm -rf "$pkgdir/usr/lib/python$_pyver/site-packages/tests/"
}

